package com.ygqh.baby.service.wechat;

import java.util.Enumeration;
import java.util.ResourceBundle;

import com.foxinmy.weixin4j.model.WeixinAccount;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.ygqh.baby.service.wechat.api.YgPay3Api;

public class WxConfig {

	private final static WeixinPayAccount wxPayAccount;
	private final static WeixinAccount wxAccount;
	private final static WeixinPayAccount smallPayAccount;
	private final static WeixinAccount smallAccount;

	private final static YgPay3Api wxPayApi;
	private final static YgPay3Api smallPayApi;

	private final static String wxCertUrl;// M站 公众号 支付证书阿里云地址
	private final static String smallCertUrl;// M站 小程序 支付证书阿里云地址
	private final static String providerCertUrl;// 壹家店 小程序 支付证书阿里云地址
	private final static String wxOrderPayNotifyUrl;// 统一下单回调地址
	private final static String wxFwsOrderPayNotifyUrl;// 统一下单回调地址

	static {
		ResourceBundle WX_BUNDLE = ResourceBundle.getBundle("prop/pay");
		Enumeration<String> keys = WX_BUNDLE.getKeys();
		String string = keys.toString();
		System.out.println(string);

		// 公用配置
		wxOrderPayNotifyUrl = WX_BUNDLE.getString("m.pay.notify_url");
		wxFwsOrderPayNotifyUrl = WX_BUNDLE.getString("wx.fws.pay.notifyUrl");

		providerCertUrl = "cert/provider/apiclient_cert.p12";

		// android配置
		String samllAppId = WX_BUNDLE.getString("m.small.appId");
		String smallSecret = WX_BUNDLE.getString("m.small.secret");
		String smallPaySignKey = WX_BUNDLE.getString("m.small.key");
		String smallMchId = WX_BUNDLE.getString("m.small.mchId");
		smallCertUrl = "cert/small/apiclient_cert.p12";

		String wxAppId = WX_BUNDLE.getString("m.wx.appId");
		String wxSecret = WX_BUNDLE.getString("m.wx.secret");
		String wxPaySignKey = WX_BUNDLE.getString("m.wx.key");
		String wxMchId = WX_BUNDLE.getString("m.wx.mchid");
		wxCertUrl = "cert/apiclient_cert.p12";

		// 公众号
		wxPayAccount = new WeixinPayAccount(wxAppId, wxSecret, wxPaySignKey, wxMchId);
		wxAccount = new WeixinAccount(wxAppId, wxSecret);

		// 小程序
		smallPayAccount = new WeixinPayAccount(samllAppId, smallSecret, smallPaySignKey, smallMchId);
		smallAccount = new WeixinAccount(samllAppId, smallSecret);

		//
		// wxOrderPayNotifyUrl =
		// "http://yiigoo.3w.net579.com/mobile/order/unifiedOrderCallBack.do";
		// wxPayAccount = new WeixinPayAccount("wx563327e8dd35e422",
		// "040479c33377924cde20854e9f73d6ce",
		// "K7YWPHBTZJ8QCFVNG03IML514ES2DX96", "1320346801");
		// smallPayAccount = new WeixinPayAccount("wx403bd9330d4b5144",
		// "b17132b37326578500ec0530f84d7dc6",
		// "sjdkasjiiHUhdsanoi213dkodpsajonJ", "1415744002");

		wxPayApi = new YgPay3Api(wxPayAccount);
		smallPayApi = new YgPay3Api(smallPayAccount);

	}

	
	public static String getWxfwsorderpaynotifyurl() {
		return wxFwsOrderPayNotifyUrl;
	}

	public static WeixinPayAccount getWxpayaccount() {
		return wxPayAccount;
	}

	public static WeixinAccount getWxaccount() {
		return wxAccount;
	}

	public static WeixinPayAccount getSmallpayaccount() {
		return smallPayAccount;
	}

	public static WeixinAccount getSmallaccount() {
		return smallAccount;
	}

	public static String getWxcerturl() {
		return wxCertUrl;
	}

	public static String getSmallcerturl() {
		return smallCertUrl;
	}

	public static String getWxorderpaynotifyurl() {
		return wxOrderPayNotifyUrl;
	}

	public static YgPay3Api getWxpayapi() {
		return wxPayApi;
	}

	public static YgPay3Api getSmallpayapi() {
		return smallPayApi;
	}

	public static String getProvidercerturl() {
		return providerCertUrl;
	}

}
